from . import db
import datetime


class CarInfo(db.Model):
    __tablename__ = "li_car_info"

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    create_time = db.Column(db.DateTime, doc="创建时间", default=datetime.datetime.utcnow())
    car_num = db.Column(db.String(256), doc="车号")
    asset_code = db.Column(db.String(256), doc="资产编码")
    vin_num = db.Column(db.String(256), doc="VIN编码")
    deleted = db.Column(db.Boolean, default=False)
    ruel_cost = db.relationship(
        "RuelCost",
        backref=db.backref("cars"),
        lazy="dynamic",
        passive_deletes=False,
        cascade="delete",
    )

    road_toll = db.relationship(
        "RoadToll",
        backref=db.backref("cars"),
        lazy="dynamic",
        passive_deletes=False,
        cascade="delete",
    )

    parking_rate = db.relationship(
        "ParkingRate",
        backref=db.backref("cars"),
        lazy="dynamic",
        passive_deletes=False,
        cascade="delete",
    )
    data_collection = db.relationship(
        "DataCollection",
        backref=db.backref("cars"),
        lazy="dynamic",
        passive_deletes=False,
        cascade="delete",
    )
    parking_collection = db.relationship(
        "ParkingCollection",
        backref=db.backref("cars"),
        lazy="dynamic",
        passive_deletes=False,
        cascade="delete",
    )
